#include<stdio.h>

int h[10001][5]={0}; 

int main()
{
	int n,sign,x,y,key=0,max=0;
	scanf("%d",&n);
	for(sign=0;sign<n;sign++)
	{
		scanf("%d %d %d %d",&h[sign][0],&h[sign][1],&h[sign][2],&h[sign][3]);
		
	}
	scanf("%d %d",&x,&y);
	for(sign=0;sign<n;sign++)
	{
		if(x>=h[sign][0]&&y>=h[sign][1]&&x<=h[sign][0]+h[sign][2]&&y<=h[sign][1]+h[sign][3])
		{
			max=sign+1;
			key=1;
		}
	}
	if(key==1) printf("%d",max);
	else printf("-1");
	return 0;
}
